package com.ftg.learn.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ftg.learn.system.entity.Emp;
import com.ftg.learn.system.service.IDeptService;
import com.ftg.learn.system.service.IEmpService;
import com.ftg.learn.system.vo.OrganizationVo;
import com.ftg.learn.util.JsonWeb;
import com.ftg.learn.util.JsonWebUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.List;

/**
 * 员工管理功能
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/5/9 下午3:14
 */
@Api(tags = "人事管理|员工管理")
@RequestMapping("/api/system/hr")
@RestController
public class EmpController {

    @Resource
    private IEmpService iEmpService;

    @Resource
    private IDeptService iDeptService;

    @GetMapping("/deptList")
    @ApiOperation("/查询部门树信息")
    public JsonWeb<List<OrganizationVo>> organizationList() {
        return iDeptService.organizationList();
    }


    @GetMapping("/empList")
    @ApiOperation("/人员信息列表")
    public JsonWeb<IPage<Emp>> empList(
            @ApiParam("姓名") @RequestParam(value = "empName", required = false) String empName,
            @ApiParam("性别") @RequestParam(value = "empGender", required = false) Integer empGender,
            @ApiParam("邮箱") @RequestParam(value = "empEmail", required = false) String empEmail,
            @ApiParam("部门id") @RequestParam(value = "empDeptId", required = false) BigInteger empDeptId,
            @ApiParam(value = "页码", required = true) @RequestParam(value = "pageNo", defaultValue = "1") Long pageNo,
            @ApiParam(value = "数据条数", required = true) @RequestParam(value = "pageSize", defaultValue = "10") Long pageSize
    ) {
        return iEmpService.empList(empName, empGender, empEmail, empDeptId, pageNo, pageSize);
    }

}
